interface Storage {
  setStorageItem(key: string | number, val: string): void,

  getStorageItem(key: string | number): any,

  removeStorageItem(key: string | number): void,

  setStorageAccounts(key: string | number, val: string): void,

  getStorageAccounts(key: string | number): any,
}

class BfStorage implements Storage {
  setStorageItem(key, val) {
    window.localStorage.setItem(key, val);
  }

  getStorageItem(key) {
    return window.localStorage.getItem(key);
  }

  removeStorageItem(key) {
    window.localStorage.removeItem(key);
  };

  setStorageAccounts(val = "") {
    let key = "bf-login-accounts";
    this.setStorageItem(key, val)
  }

  getStorageAccounts() {
    let key = "bf-login-accounts";
    let accounts = this.getStorageItem(key);
    if (accounts) {
      accounts = JSON.parse(accounts);
    }
    return accounts;
  }
}

export default new BfStorage();

